<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Account console</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js" async="async"></script>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='stylesheets/admin.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='stylesheets/index.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='stylesheets/window.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='stylesheets/tw.css') }}">
    <script src="{{ url_for('static',filename='javascript/edit_account.js') }}"></script>
    <script>
        function addStudent1() {
            var studentList = document.getElementById('student-list');
            var newInput = document.createElement('input');
            newInput.type = 'text';
            newInput.name = 'student';
            newInput.setAttribute('class', 'input mb-3');
            newInput.required = true;
            studentList.appendChild(newInput);
        }
        function addStudent2() {
            var studentList = document.getElementById('student-list2');

            var newInput = document.createElement('input');
            newInput.type = 'text';
            newInput.name = 'student';
            newInput.setAttribute('class', 'input mb-3');
            newInput.required = true;
            studentList.appendChild(newInput);
        }
    </script>
</head>

<body>
    <div class="edit_form">
        <p>{{ mode }}</p>

        <!-- 创建帖子 -->
        {% if mode == "Create Forum"%}
        <form name="create_forum" method="post">
            <label for="forum_id">ID</label>
            <input name="forum_id" id="forum_id" type="text" required class="input mb-3">

            <label for="title">Title</label>
            <input name="title" id="title" type="text" required class="input mb-3">

            <label for="content">Content</label>
            <textarea name="content" id="content" rows="4" required class="input h-auto mb-3"></textarea>

            <label for="category">Forum Category</label>
            <div class="mb-5 w-36 relative">
                <select name="category" id="category" required class="select w-full">
                    <option value="-1">xxx</option>
                    <option value="0">xxx</option>
                    <option value="1">xxx</option>
                </select>
                <svg
                    class="absolute right-2 top-1.5 pointer-events-none"
                    viewBox="0 0 1024 1024"
                    xmlns="http://www.w3.org/2000/svg"
                    width="20"
                    height="20"
                ><path d="M819.2 403.2l-275.2 288c-19.2 19.2-44.8 19.2-64 0L204.8 403.2c-19.2-19.2-19.2-51.2 0-70.4 19.2-19.2 44.8-19.2 64 0l243.2 256 243.2-256c19.2-19.2 44.8-19.2 64 0 19.2 19.2 19.2 51.2 0 70.4z" fill="#6b7280"></path>
                </svg>
            </div>

            <input name="submit" id="edit" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        <!-- 评论帖子 -->
        {% if mode == "Comment Forum"%}
        <form name="comment_forum" method="post">
            <label for="forum_id">Forum ID</label>
            <input name="forum_id" id="forum_id" type="text" value="{{forum[0]}}" readonly class="input mb-3">

            <label for="category">Category</label>
            <input name="category" id="category" type="text" value="{{ forum[1] }}" readonly class="input mb-3">

            <label for="title">Title</label>
            <input name="title" id="title" type="text" value="{{ forum[2] }}" readonly class="input mb-3">

            <label for="content">Content</label>
            <textarea name="content" id="content" rows="4" readonly class="input h-auto mb-3">{{forum[3]}}</textarea>

            <label for="author">Author</label>
            <input name="author" id="author" type="text" value="{{ forum[4] }}" readonly class="input mb-3">

            <label for="created_at">Created At</label>
            <input name="created_at" id="created_at" type="text" value="{{ forum[5] }}" readonly class="input mb-3">

            <h3 class="mb-2 pb-2 border-b">Comments List</h3>
            <ul class="mb-5 none-list-style">
                {% for comment in comments %}
                <li class="flex flex-col border-b pb-2 mb-2">
                    <div>{{ comment[0] }}: {{ comment[1] }}</div>
                    <div class="self-end">{{ comment[2] }}</div>
                </li>
                {% endfor %}
                <!-- <li class="flex flex-col border-b pb-2 mb-2">
                    <div>评论人: 评论内容</div>
                    <div class="self-end">评论时间</div>
                </li> -->
            </ul>

            <h3 class="mb-2">Add A Comment</h3>
            <textarea name="comment" id="content" rows="4" required class="input h-auto mb-5"></textarea>

            <input name="submit" id="submit" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Edit Mode"%}
        <form name="edit_form" method="post">
            <label for="ID">ID</label>
            <input name="ID" id="ID" type="text" value="{{user_id}}" readonly class="input mb-3">

            <label for="Fullname">Fullname</label>
            <input name="Fullname" id="Fullname" type="text" value="{{ Fullname }}" required class="input mb-3">

            <label for="password">Password</label>
            <input name="password" id="password" type="password" required class="input mb-3">

            <label for="confirm_password">Confirm password</label>
            <input name="confirm_password" id="confirm_password" type="password" required class="input mb-3">

            <label for="User_Type">User Type</label>
            <div class="mb-5 w-36 relative">
                <select name="User_Type" id="User_Type" required class="select w-full">
                    <option value="-1">Administrator</option>
                    <option value="0">Instructor</option>
                    <option value="1">Student</option>
                </select>
                <svg
                    class="absolute right-2 top-1.5 pointer-events-none"
                    viewBox="0 0 1024 1024"
                    xmlns="http://www.w3.org/2000/svg"
                    width="20"
                    height="20"
                ><path d="M819.2 403.2l-275.2 288c-19.2 19.2-44.8 19.2-64 0L204.8 403.2c-19.2-19.2-19.2-51.2 0-70.4 19.2-19.2 44.8-19.2 64 0l243.2 256 243.2-256c19.2-19.2 44.8-19.2 64 0 19.2 19.2 19.2 51.2 0 70.4z" fill="#6b7280"></path>
                </svg>
            </div>

            <input name="submit" id="edit" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {%if mode == "View Mode"%}
        <form>
            <label for="ID1">ID</label>
            <input name="ID" id="ID1" type="text" value="{{user_id}}" disabled class="input mb-3">

            <label for="Fullname">Fullname</label>
            <input name="Fullname" id="Fullname1" type="text" value="{{ Fullname }}" disabled class="input mb-3">

            <label for="User_Type">User Type</label>
            <input name="User_Type" id="User_Type1" value="{{kind}}" disabled class="input mb-5">

            <button id="view" onclick="window.location.href='/account';" class="input-btn w-24 mx-auto">Got it!</button>
        </form>
        {% endif %}

        {% if mode == "Create Mode"%}
        <form name="create_form" method="post">
            <label for="ID">ID</label>
            <input name="ID" id="ID2" type="text" required class="input mb-3">

            <label for="Fullname">Fullname</label>
            <input name="Fullname" id="Fullname2" type="text" required class="input mb-3">

            <label for="password">Password</label>
            <input name="password" id="password2" type="password" required class="input mb-3">

            <label for="confirm_password">Confirm password</label>
            <input name="confirm_password" id="confirm_password2" type="password" required class="input mb-3">

            <label for="User_Type">User Type</label>
            <div class="mb-5 w-36 relative">
                <select name="User_Type" id="User_Type2" required class="select w-full">
                    <option value="-1">Administrator</option>
                    <option value="0">Instructor</option>
                    <option value="1">Student</option>
                </select>
                <svg
                    class="absolute right-2 top-1.5 pointer-events-none"
                    viewBox="0 0 1024 1024"
                    xmlns="http://www.w3.org/2000/svg"
                    width="20"
                    height="20"
                ><path d="M819.2 403.2l-275.2 288c-19.2 19.2-44.8 19.2-64 0L204.8 403.2c-19.2-19.2-19.2-51.2 0-70.4 19.2-19.2 44.8-19.2 64 0l243.2 256 243.2-256c19.2-19.2 44.8-19.2 64 0 19.2 19.2 19.2 51.2 0 70.4z" fill="#6b7280"></path>
                </svg>
            </div>

            <input name="submit" id="edit2" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Edit Mode Course"%}
        <form name="edit_form_course" method="post">
            <label for="course_id">ID</label>
            <input name="course_id" id="course_id" type="text" value="{{results[0]}}" readonly class="input mb-3">

            <label for="course_name">Course Name</label>
            <input name="course_name" id="course_name" type="text" value="{{ results[1] }}" required class="input mb-3">

            <label for="instructor_name">Instructor Name</label>
            <input name="instructor_name" id="instructor_name" type="text" value="{{ results[2] }}" required class="input mb-3">

            <textarea name="description" id="description" rows="4" required class="input h-auto mb-3">{{results[3]}}</textarea>

            <h3 class="mb-2">Registered Students</h3>
            <ul class="mb-3">
                {% for student in students %}
                <li>
                    {{ student[0] }} (ID: {{ student[1] }})
                    <button
                        class="warn-btn"
                        onclick="window.location.href='/course/delete_student?course_id={{ user_id }}&student_id={{ student[1] }}';"
                    >Delete</button>
                </li>
                {% endfor %}
            </ul>

            <h3 class="mb-2">Add Students</h3>
            <div id="student-list2" class="flex flex-col"></div>
            <button class="main-btn w-36 mb-5" onclick="addStudent2()">Add Student</button>

            <input name="submit" id="submit" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Create Mode Course"%}
        <form name="create_form_course" method="post">
            <label for="ID">ID</label>
            <input name="course_id1" id="course_id1" type="text" required class="input mb-3">

            <label for="course_name">Course Name</label>
            <input name="course_name1" id="course_name1" type="text" required class="input mb-3">

            <label for="instructor_name">Instructor Name</label>
            <input name="instructor_name1" id="instructor_name1" type="text" required class="input mb-3">

            <label for="instructor_id">Instructor ID</label>
            <input name="instructor_id" id="instructor_id" type="text" required class="input mb-3">

            <textarea name="description1" id="description1" rows="4" placeholder="Course Description" required class="input h-auto mb-3"></textarea>

            <div id="student-list" class="flex flex-col"></div>
            <button class="main-btn w-36 mb-5" onclick="addStudent1()">Add Student</button>

            <input name="submit" id="edit3" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Create Mode Lecture"%}
        <form name="create_form_lecture" method="post" enctype="multipart/form-data">
            <label for="ID1">Lecture ID</label>
            <input name="lecture_id" id="lecture_id1" type="text" required class="input mb-3">

            <label for="lecture_name">Lecture Name</label>
            <input name="lecture_name" id="lecture_name" type="text" required class="input mb-3">

            <label for="course_name">Course Name</label>
            <input name="course_name" id="course_name3" type="text" required class="input mb-3">

            <label for="instructor_name1">Instructor Name</label>
            <input name="instructor_name" id="instructor_name3" type="text" required class="input mb-3">

            <textarea name="description" id="description2" rows="4" required class="input h-auto mb-3">Description</textarea>
            
            <div class="mb-5">
                <span class="mb-2 block">File:</span>
                <input type="file" name="uploaded_file">
            </div>

            <input name="submit" id="edit5" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Edit Mode Lecture"%}
        <form name="edit_form_lecture" method="post" enctype="multipart/form-data">
            <label for="lecture_id5">ID</label>
            <input name="lecture_id" id="lecture_id5" type="text" value="{{results[0]}}" readonly class="input mb-3">

            <label for="lecture_name5">Lecture Name</label>
            <input name="lecture_name" id="lecture_name5" type="text" value="{{ results[2] }}" required class="input mb-3">

            <label for="instructor_name">Instructor Name</label>
            <input name="instructor_name" id="instructor_name5" type="text" value="{{ results[3] }}" required class="input mb-3">

            <textarea name="description" id="description5" rows="4" placeholder="Course Description" required class="input h-auto mb-3">{{results[4]}}</textarea>

            <div class="mb-5">
                <span class="mb-2 block">File:</span>
                <input type="file" name="uploaded_file">
            </div>

            <input name="submit" id="submit1" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Create Mode Assignment"%}
        <form name="edit_form_assignment" method="post" enctype="multipart/form-data">
            <label for="course_id">Course ID</label>
            <input name="course_id" id="course_id6" type="text" value="{{course_id}}" readonly class="input mb-3">

            <label for="course_name">Course Name</label>
            <input name="course_name" id="course_name6" type="text" value="{{ course_name }}" readonly class="input mb-3">

            <label for="assignment_id">Assignment ID</label>
            <input name="assignment_id" id="assignment_id" type="text" required class="input mb-3">

            <label for="assignment_name">Assignment Name</label>
            <input name="assignment_name" id="assignment_name" type="text" required class="input mb-3">

            <textarea name="description" id="description6" rows="4" placeholder="Course Description"required class="input h-auto mb-5"></textarea>

            <input name="submit" id="submit2" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Create Mode Submission"%}
        <form name="create_form_submission" method="post" enctype="multipart/form-data">
            <label for="assignment_id">Assignment ID</label>
            <input name="assignment_id" id="assignment_id1" type="text" value="{{assignment_id}}" readonly class="input mb-3">

            <label for="assignment_name">Assignment Name</label>
            <input name="assignment_name" id="assignment_name1" type="text" value="{{assignment_name}}" readonly class="input mb-3">

            <textarea name="description" id="description7" rows="4" readonly class="input h-auto mb-3">{{description}}</textarea>

            <div class="mb-5">
                <span class="mb-2 block">File:</span>
                <input type="file" name="uploaded_file">
            </div>

            <input name="submit" id="submit3" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}

        {% if mode == "Create Mode Mark"%}
        <form name="create_form_mark" method="post" enctype="multipart/form-data">
            <label for="assignment_id">Assignment ID</label>
            <input name="assignment_id" id="assignment_id2" type="text" value="{{information[2]}}" readonly class="input mb-3">

            <label for="submission_id">Submission ID</label>
            <input name="submission_id" id="submission_id" type="text" value="{{information[0]}}" readonly class="input mb-3">

            <label for="student_id">Student ID</label>
            <input name="student_id" id="student_id" type="text" value="{{information[1]}}" readonly class="input mb-3">

            <label for="score">Score</label>
            <input name="score" id="score" type="text" required class="input mb-3">

            <textarea name="comments" id="comments" rows="4" placeholder="Comments" required class="input h-auto mb-5"></textarea>

            <input name="submit" id="submit5" type="submit" value="Submit" class="input-btn w-24 mx-auto">
        </form>
        {% endif %}
    </div>
</body>

</html>